package me.jessyan.armscomponent.app.mvp.ui.util;

import android.app.Application;
import android.app.ProgressDialog;
import android.content.Context;

public class DialogUtil {
    ProgressDialog progressDialog;
    private Context mContext;
    private static DialogUtil instants;

    public static DialogUtil getInstants(Context context){
        if(instants == null){
            instants = new DialogUtil(context);
        }
        return instants;
    }

    public DialogUtil(Context mContext){
        this.mContext = mContext;
        initProgressDialog();
    }

    private void initProgressDialog() {
        progressDialog = new ProgressDialog(mContext);
        progressDialog.setIndeterminate(false);//循环滚动
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.setMessage("loading...");
        progressDialog.setCancelable(false);//false不能取消显示，true可以取消显示
    }

    public void showProgressDialog(){
        if(progressDialog != null){
            progressDialog.show();
        }
    }

    public void hideProgressDialog(){
        if(progressDialog != null){
            progressDialog.hide();
        }
    }
}
